package org.nokatag.code;

public class WobbleImageOp extends AbstractTransformImageOp
{

    private double xWavelength;
    private double yWavelength;
    private double xAmplitude;
    private double yAmplitude;
    private double xRandom;
    private double yRandom;
    private double xScale;
    private double yScale;

    public WobbleImageOp()
    {
        xWavelength = 15D;
        yWavelength = 15D;
        xAmplitude = 4D;
        yAmplitude = 3D;
        xScale = 1.0D;
        yScale = 1.0D;
        xRandom = 3D * Math.random();
        yRandom = 10D * Math.random();
    }

    public double getxWavelength()
    {
        return xWavelength;
    }

    public void setxWavelength(double xWavelength)
    {
        this.xWavelength = xWavelength;
    }

    public double getyWavelength()
    {
        return yWavelength;
    }

    public void setyWavelength(double yWavelength)
    {
        this.yWavelength = yWavelength;
    }

    public double getxAmplitude()
    {
        return xAmplitude;
    }

    public void setxAmplitude(double xAmplitude)
    {
        this.xAmplitude = xAmplitude;
    }

    public double getyAmplitude()
    {
        return yAmplitude;
    }

    public void setyAmplitude(double yAmplitude)
    {
        this.yAmplitude = yAmplitude;
    }

    public double getxScale()
    {
        return xScale;
    }

    public void setxScale(double xScale)
    {
        this.xScale = xScale;
    }

    public double getyScale()
    {
        return yScale;
    }

    public void setyScale(double yScale)
    {
        this.yScale = yScale;
    }

    protected void transform(int x, int y, double t[])
    {
        double tx = Math.cos((xScale * (double)x + (double)y) / xWavelength + xRandom);
        double ty = Math.sin((yScale * (double)y + (double)x) / yWavelength + yRandom);
        t[0] = (double)x + xAmplitude * tx;
        t[1] = (double)y + yAmplitude * ty;
    }
}

